# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=iamb
pkgver=0.0.8
pkgrel=1
pkgdesc="Rust Matrix chat client with Vim keybindings"
url="https://iamb.chat/"
# armhf: error: Undefined temporary symbol .LBB365_2
# armv7/x86: fails tests
# s390x: nix crate
arch="all !x86 !armv7 !armhf !s390x"
license="Apache-2.0"
makedepends="
	cargo
	cargo-auditable
	mandown
	openssl-dev
	"
subpackages="$pkgname-doc"
source="https://github.com/ulyssa/iamb/archive/v$pkgver/iamb-$pkgver.tar.gz
	example-config.patch
	getrandom-0.2.10.patch
	openssl.patch
	reduce-cpu-usage.patch
	"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release

	mandown docs/iamb.1.md > docs/iamb.1
	mandown docs/iamb.5.md > docs/iamb.5
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/iamb -t "$pkgdir"/usr/bin

	install -Dm644 docs/iamb.1 -t "$pkgdir"/usr/share/man/man1
	install -Dm644 docs/iamb.5 -t "$pkgdir"/usr/share/man/man5

	install -Dm644 docs/example_config.json \
		-t "$pkgdir"/usr/share/doc/$pkgname/examples
}

sha512sums="
f8e57a11d6344573c3c3d0c18f09d59affad2ab36be4c89d5e0657d17540ecef67b685d1fe574828bbb7c5963d52505f23f66e17c62072ca3b11f1ae594e4ae1  iamb-0.0.8.tar.gz
95a6021ec81b5450bbef003a134e7fdf9aa290525a5b8783f4720ea44fb1064031a4b53be24278adee1bb8c0fea43fc84531038504b668b10ec1446038cee72b  example-config.patch
f5b0b4598d848637c0d41fec8958234e256bbf58584fdee28fc0f2c993062758c6f6ce02b7ea5465dfc99996be5bc5094b10fbb2019cce2dcb02f8f0331700f7  getrandom-0.2.10.patch
f9de8a9349db342bbe182c3ac833a9207afd03c211c46dd0b8cbb732370f2046ac16ed46d0f952bef798763a7efb02712f5369261b5abacbdf63bc65e2ad8703  openssl.patch
099a7592f193f2aafb35abb3293527bfd52a34d5b8cce1709ce9dc6ea6ba8bca453d6c51057fc4a74ab216a22a84397d6fa81b0044a3d552c6c6dde2074c7503  reduce-cpu-usage.patch
"
